package com.guigu.liuyunan.controller;

import com.github.pagehelper.PageInfo;
import com.guigu.liuyunan.pojo.LYNPageVo;
import com.guigu.liuyunan.pojo.Meals;
import com.guigu.liuyunan.pojo.Mealstype;
import com.guigu.liuyunan.service.MealsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("LYN")
public class MealsController {

    @Autowired
    MealsService ms;


    @PostMapping("mealsInfo")
    public PageInfo<Meals> mealsInfo(@RequestBody LYNPageVo pageVo){
        if (pageVo.getName()!=null){
            pageVo.setName(pageVo.getName().trim());
        }
        return ms.mealsInfo(pageVo);
    }

    @PostMapping("mealsTypeInfo")
    public List<Mealstype> mealsTypeInfo(){
        return ms.mealsTypeInfo();
    }

    @GetMapping("delMeals")
    public int delMeals(Integer id){
        return ms.delMeals(id);
    }

    @PostMapping("addMeals")
    public int addMeals(@RequestBody Meals meals){
        return ms.addMeals(meals);
    }

    @PostMapping("upMeals")
    public int upMeals(@RequestBody Meals meals){
        return ms.upMeals(meals);
    }

}
